﻿<?php
@session_start();

require_once("../../class/mysql.class.php");

  $obj = new Mysql();
  
  $obj -> set_table('user_login');
  $obj -> set_colone("(`*`)");
  $obj -> set_variables(" id_login = '" . $_SESSION["id"] . "' ");
  $user = $obj -> select_enregistrement();
 // echo $user['id_login'];
  
	if (isset($_REQUEST['type_article']))
	{

			$type_article = addslashes($_REQUEST["type_article"]); 
			$desc = addslashes($_REQUEST["desc_article"]); 
			$req = "SELECT * FROM `st_att_type_article` WHERE nom_type='".$type_article."'";
			$obj = new Mysql ();
			$r=mysql_query($req);
		if(mysql_num_rows($r)<1){
			$sql = "INSERT INTO `st_att_type_article` (`id_type`, `nom_type`,`description`) 
			VALUES 
			('', '".$type_article."','".$desc."');";
			mysql_query($sql);
			header('location:../../list_type_articles.php?action=added&type='.$type_article);
		}else{
			header('location:../../list_type_articles.php?action=addedError&type='.$type_article);
		}
}
